#include <iostream>
using namespace std;
#include <queue>

struct Date
{
	int _year;
	int _month;
	int _day;

	Date(int year, int month, int day)
		:_year(year)
		,_month(month)
		,_day(day)
	{}

	friend bool operator<(const Date& d1, const Date& d2);
	friend ostream& operator<<(ostream& out, const Date& d);

};



ostream& operator<<(ostream& out, const Date& d)
{
	out << d._year << " " << d._month << " " << d._day;
	return out;
}

//template<class T>
//bool Less(T a, T b)
//{
//	return a < b;
//}
//
//template<>
//bool Less<Date*>(Date* a, Date* b)
//{
//	return *a < *b;
//}

template<class T>
struct Less
{
	bool operator()(T& a, T& b)
	{
		return a < b;
	}
};

//bool operator<(Date d1, Date d2)
//{
//	if (d1._year < d2._year)
//		return true;
//	else if (d1._year == d2._year && d1._month < d2._month)
//		return true;
//	else if (d1._year == d2._year && d1._month == d2._month && d1._day < d2._day)
//		return true;
//
//	return false;
//}

template<>
struct Less<Date*>
{
	bool operator()(const Date* a, const Date* b)
	{
		return *a < *b;
	}
};


int main()
{
	/*cout << Less(1, 2) << endl;

	Date d1(2021, 10, 2);
	Date d2(2024, 3, 6);

	cout << Less(d1, d2) << endl;

	Date* p1 = &d1;
	Date* p2 = &d2;

	cout << Less(p1, p2) << endl;*/

	priority_queue<Date, vector<Date*>, Less<Date*>> pq;
	pq.push(new Date(2021, 10, 2));
	pq.push(new Date(2022, 11, 2));
	pq.push(new Date(2024, 3, 4));


	while (!pq.empty())
	{
		cout << pq.top() << endl;
		pq.pop();
	}
	cout << endl;
	return 0;
}